package com.medicine.hbp.ui;

import org.kymjs.kjframe.http.HttpParams;
import org.kymjs.kjframe.ui.BindView;

import android.view.View;
import android.view.View.OnClickListener;

import com.medicine.hbp.adapter.UserListAdapter;
import com.medicine.hbp.base.BaseActivity;
import com.medicine.hbp.http.AppHttpCallBack;
import com.medicine.hbp.http.AppHttps;
import com.medicine.hbp.http.HttpInterface;
import com.medicine.hbp.mob.FindMessageListVo;
import com.medicine.hbp.uitl.ToastUtil;
import com.medicine.hbp.xListView.XListView;
import com.medicine.hbp.xListView.XListView.IXListViewListener;
import com.medicine.hbp.R;

/**
 * 这里是@我聊天列表
 *
 * @author yusuojindan
 */
public class UserListActivity extends BaseActivity implements IXListViewListener {
	@BindView(id=R.id.xListView_userlist,click=false)
	public XListView xListView_userlist;

	private UserListAdapter adapter;
	@Override
	public void setRootView() {
		super.setRootView();
		setContentView(R.layout.activity_userlist);
	}

	@Override
	public void initWidget() {
		super.initWidget();
		adapter=new UserListAdapter(aty);
		xListView_userlist.setAdapter(adapter);
		xListView_userlist.setXListViewListener(this);
		xListView_userlist.setPullLoadEnable(false);
		xListView_userlist.setPullRefreshEnable(false);
		initTop();
		httpFindMessageList();
	}

	@Override
	public void widgetClick(View v) {
		super.widgetClick(v);
	}

	private void httpFindMessageList() {
		HttpParams params = new HttpParams();
		AppHttps.HttpPost(this,HttpInterface.FIND_MESSAGE_LIST, params,
				new AppHttpCallBack<FindMessageListVo>(FindMessageListVo.class,
						aty) {
					@Override
					public void onSuccess(FindMessageListVo result) {
						adapter.setItems(result.messageList);
						adapter.notifyDataSetChanged();
					}

					@Override
					public void onFailures(int errorCode, String errorMsg) {
						ToastUtil.showShort(aty, errorMsg);
					}
				});
	}
	private void initTop() {
		TopView topview = (TopView) findViewById(R.id.topview);
		topview.setTitle("消息列表");
		topview.setLeftVisibility(View.GONE);
		topview.setLeftVisibilityExit(View.VISIBLE);
		topview.setRightVisibility(View.INVISIBLE);
		topview.setLeftOnClickExit(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				finish();
			}
		});
	}

	@Override
	public void onRefresh() {
		// TODO Auto-generated method stub

	}

	@Override
	public void onLoadMore() {
		// TODO Auto-generated method stub

	}
}
